package com.ddwl.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author hemiaojun
 * @Date 2020/9/17 10:39
 */
public interface OperateLogEnum {

    //String UPDATE_INVITE_CODE_URI="/user/inviteCode/update";

    @AllArgsConstructor
    @Getter
    enum typeEnum {
        UPDATE_INVITE_CODE("0","/user/inviteCode/update", "修改邀请人"),
        CONSOLE_LOGIN("1","/user/login", "后台登录"),
        CONSOLE_LOGOUT("2","/user/logout", "后台登出"),
        APP_LOGIN("3","/user/appLogin", "app登录"),
        ;

        private String code;
        private String uri;
        private String desc;

        public static String getTypeCode(String uri) {
            for (OperateLogEnum.typeEnum typeEnum : values()) {
                if (typeEnum.getUri().equals(uri)) {
                    return typeEnum.getCode();
                }
            }
            return null;
        }
    }

    @AllArgsConstructor
    @Getter
    enum statusEnum {
        SUCCESS((byte)1, "成功"),
        FAILURE((byte)0, "失败"),
        ;

        private Byte code;
        private String desc;
    }

    @AllArgsConstructor
    @Getter
    enum SearchPropertyEnum {
        URI(0,"uri"),
        DK(1, "dk"),
        IP(2, "ip"),
        USER_ID(3, "operateId"),
        ;

        private Integer  code;
        private String property;

        public static String getSearchProperty(Integer code) {
            for (OperateLogEnum.SearchPropertyEnum searchPropertyEnum : values()) {
                if (searchPropertyEnum.getCode().equals(code)) {
                    return searchPropertyEnum.getProperty();
                }
            }
            return null;
        }

    }

}
